package com.dtguai.app.common.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * @author guo
 * @date 2020年4月1日11:03:24
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BaseContext {

    private static final ThreadLocal<Integer> USER_ID_LOCAL = new TransmittableThreadLocal<>();

    public static void set(Integer id) {
        USER_ID_LOCAL.set(id);
    }

    public static Integer get() {
        return USER_ID_LOCAL.get();
    }

    public static void setUserId(Integer id) {
        set(id);
    }

    public static void remove() {
        USER_ID_LOCAL.remove();
    }


}
